#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int n,a[10], b[10] = { 0 }, temp, mark;
	cin >> n;
	for (int i = 0; i < 7; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		mark = 0;
		
		for (int j = 0; j < 7; j++)
		{
			cin >> temp;
			for (int k = 0; k < 7; k++)
			{
				if (a[k] == temp)
				{
					mark++;
					break;
				}
			}
		}
		b[mark]++;
	}
	for (int i = 7; i >= 1; i--)
	{
		cout << b[i] << " ";
	}
	return 0;
}